/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn;

import com.baomidou.mybatisplus.core.toolkit.AES;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

/**
 * <p>Project: mp2022 - Demo
 * <p>Powered by webrx On 2022-04-16 16:59:43
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Demo {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql:/oadb", "root", "")
                .globalConfig(builder -> {
                    builder.author("webrx") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            //.fileOverride() // 覆盖已生成文件
                            .outputDir("D:\\mp\\src\\main\\java\\"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("cn.webrx") // 设置父包名
                            .moduleName("system") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "D:\\mp\\src\\main\\resources\\mapper\\")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("book"/*此处t_book t_goods 如果不填写则全部生成*/) // 设置需要生成的表名
                            .addTablePrefix("t_", "c_","w_"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }

    public static void cc(String[] args) {
        String randomKey = AES.generateRandomKey();
        System.out.println(randomKey);
        // 随机密钥加密 -- 62a2104ab33067d4
        String root = AES.encrypt("root", randomKey);
        System.out.println(root); //qXVqkN34N7ASVJvWDPianw==
        String url = AES.encrypt("jdbc:mysql:/oadb", randomKey);
        System.out.println(url);//CQasB091BEigdKR1VwKqZVK++2ZehM0bEy2A0DbCY7k=
    }
}
